{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Direct Debit Extract",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "identifier" : {
      "type" : "integer",
      "description" : "Unique identifier for each generic extract file than is produced by CMP."
    },
    "jobCode" : {
      "type" : "string",
      "maxLength" : 10,
      "description" : "Unique identfier of the CMP job that produces this extract file. "
    },
    "jobDescription" : {
      "type" : "string",
      "maxLength" : 50,
      "description" : "A short description of the CMP job that produces this extract file. "
    },
    "version" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 99.99,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "Payments" ],
      "description" : "CMP categorization of the job that produces this extract file."
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "Recurring Bank Payments" ],
      "description" : "CMP sub-categorization of the job that produces this extract file. "
    },
    "batchDateAndTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the batch was created in CMP. "
    },
    "extractDateAndTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the generic extract file was created."
    },
    "recordCount" : {
      "type" : "integer",
      "description" : "Total number of transaction records in the extract file. "
    },
    "extractUpToDate" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Only payments due on or before this date are included in the extract file. "
    },
    "paymentTotal" : {
      "type" : "number",
      "minimum" : 1.0,
      "maximum" : 9.999999999999998E13,
      "description" : "Total value of payment transactions in the extract file."
    },
    "paymentCount" : {
      "type" : "integer",
      "description" : "Total number of payment transactions in the extract file."
    },
    "refundTotal" : {
      "type" : "number",
      "maximum" : 9.999999999999998E13,
      "description" : "Total value of refunds transactions in the extract file."
    },
    "refundCount" : {
      "type" : "integer",
      "description" : "Total number of refund transactions in the extract file."
    },
    "details" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/DirectDebitExtractDetail"
      }
    }
  },
  "required" : [ "identifier", "jobCode", "jobDescription", "version", "interfaceCategory", "interfaceType", "batchDateAndTime", "extractDateAndTime", "recordCount", "extractUpToDate", "paymentTotal", "paymentCount", "refundTotal", "refundCount" ],
  "definitions" : {
    "DirectDebitExtractDetail" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "detailSequence" : {
          "type" : "integer",
          "description" : "Unique identifier of the detail record within the current extract"
        },
        "accountNumber" : {
          "type" : "integer",
          "description" : "Unique identifier of the account in CMP."
        },
        "transactionType" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 7,
          "description" : "Payment or refund indicator."
        },
        "paymentType" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "CMP code representing the type of card e.g. VISA, MASTER "
        },
        "amount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.999999999999E10,
          "description" : "Amount of the payment or refund "
        },
        "transactionNumber" : {
          "type" : "integer",
          "description" : "Unique identifier of the payment/refund transaction.  This should be included in request that are sent to third-party systems. "
        },
        "retryCount" : {
          "type" : "integer",
          "description" : "This is greater than zero if a payment transaction is being retried i.e. the transaction follows a soft-decline and temporary suspension."
        },
        "mandateReference" : {
          "type" : "string",
          "description" : "Mandate reference for Bank Payment detail"
        },
        "nameOfPayer" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Name of payer"
        },
        "bankIdentifier" : {
          "type" : "string",
          "maxLength" : 20,
          "description" : "Bank identifier"
        },
        "bankAccountIdentifier" : {
          "type" : "string",
          "maxLength" : 40,
          "description" : "Bank account identifier"
        },
        "previousMandateReference" : {
          "type" : "string",
          "maxLength" : 50,
          "description" : "Previous Mandate reference for Bank Payment detail"
        },
        "previousNameOfPayer" : {
          "type" : "string",
          "maxLength" : 50,
          "description" : "Previous name of payer "
        },
        "previousBankIdentifier" : {
          "type" : "string",
          "maxLength" : 20,
          "description" : "Previous Bank identifier"
        },
        "previousBankAccountIdentifier" : {
          "type" : "string",
          "maxLength" : 40,
          "description" : "Previous Bank account identifier"
        }
      },
      "required" : [ "detailSequence", "accountNumber", "transactionType", "paymentType", "amount", "transactionNumber", "retryCount", "mandateReference", "nameOfPayer", "bankIdentifier", "bankAccountIdentifier" ]
    }
  }
}